<?php
namespace components;

class O extends Base
{
	
	public static $app;
	public $obj = [];
	public static function getInstance(){
		if(!self::$app instanceof self){
			self::$app = new self;
		}
		return self::$app;
	}
	public static function setConfig($config){
		foreach($config as $key => $val){

			self::getInstance()->$key = $val;
		}
	}
	public function __get($property){
		$config = parent::__get($property);
		if(array_key_exists('class', $config)){
			$class = $config['class'];
			unset($config['class']);
			if(isset($this->obj[$class])){
				return $this->obj[$class];
			}
			return $this->obj[$class] = new $class($config);
		}
		return $config;
	}

}